#pragma once
#include <string>
#include <map>
#include "../Headers/types.h"

namespace TOB {

  /**
   *  Configuration loader class.
   *
   *  Configuration file format:
   *
   *  # This is a commented line
   *  key=value
   *  foo=bar
   *  spaces  =    are not trimmed
   */
  class Config {
   private:
    std::map<std::string, std::string> map;

   protected:
    std::string path;

   public:
    /**
     *  Constructor
     *
     *  @param path Path to config file
     */
    Config(std::string path);

    /**
     *  Destructor
     */
    virtual ~Config();

    /**
     *  Read file
     */
    Config &read();

    /**
     *  Get string value by key.
     *  You can also change value.
     *
     *  @param key Key to be found
     */
    std::string &stringValue(std::string key);

    /**
     *  Get int value by key (kinda slow)
     *
     *  @param key Key to be found
     */
    int32 intValue(std::string key);

    /**
     *  Get float value by key (kinda slow)
     *
     *  @param key Key to be found
     */
    Float floatValue(std::string key);

    /**
     *  Simplified getting by value
     *
     *  @param [] Key to be found
     */
    std::string &operator[](std::string key);
  };
}
